package com.zhao.dota.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;

import java.io.Serializable;
import java.lang.reflect.Field;

@Data
@NoArgsConstructor
public class TotalsVo implements Serializable {

    private Integer kills;

    private Integer deaths;

    private Integer assists;

    private Integer totalEarnedGold;

    private Integer lastHitCount;

    private Integer denyCount;

    private Integer heroDamage;

    private Integer totalEarnedXp;

    private Integer firstBloodClaimed;

    private Integer firstBloodGiven;

    private Integer totalMatches;

    private Integer wins;

    private Double totalTimes;

    private Integer towerDamage;

    private Float healing;

    private Double gpm;

    private Double xpm;

    private Float stuns;

    private Integer creepsStacked;

    private Integer playerId;

    @SneakyThrows
    public TotalsVo(boolean setDefault) {
        if (setDefault) {
            Field[] declaredFields = TotalsVo.class.getDeclaredFields();
            for (Field field : declaredFields) {
                if (field.getType() == Double.class) {
                    field.set(this, 0d);
                }
                if (field.getType() == Float.class) {
                    field.set(this, 0f);
                }
                if (field.getType() == Integer.class) {
                    field.set(this, 0);
                }
                if (field.getType() == Long.class) {
                    field.set(this, 0L);
                }
            }
        }
    }
}
